package com.my.ry.common.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class HttpUtil {

	public static String getURLContent(String urlStr) {
		// 网络URL地址
		URL url = null;
		
		// http连接
		HttpURLConnection httpURLConnection = null;
		
		BufferedReader in = null;
		
		StringBuffer buffer = new StringBuffer();
		try {
			url = new URL(urlStr);
			in = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
			String str = null;
			while ((str = in.readLine()) != null) {
				buffer.append(str);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			try {
                if (in != null) {
                    in.close();
                }
            } catch (IOException ex) {
            }
		}
		
		String result = buffer.toString();
        System.out.println(result);
        return result;
	}
	
}
